﻿@model DeliveryManage.Model.Sys_User

@{
    Layout = null;
    DeliveryManage.Models.ReturnMsgModel returnMsg = ViewBag.ReturnMsgModel;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>用户编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="~/Content/font.css">
    <link rel="stylesheet" href="~/Content/framemain.css">
    <link href="~/Content/icon/iconfont.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/Content/layui/css/modules/layer/default/layer.css" />
    <script type="text/javascript" src="~/Scripts/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="~/Content/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="~/Scripts/framemain.js"></script>
    <script type="text/javascript" src="~/Scripts/laymain.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>

    <style>
        .layui-layer-contents {
            text-align: center;
            position: absolute;
            padding: 25%;
            font-size: 1rem;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            //操作提示
            if(@returnMsg.code== 400){
                layer.alert('@returnMsg.msg', { icon: 5, title: '提示' }, function (index) {
                })
            } 
            $(document).ready(function () {
                $("#myfrom").submit(function () {
                    var data = $(this).serialize();
                    layer.confirm('确认提交吗?', { icon: 3, title: '提示' }, function (index) {
                        $.ajax({
                            type: "POST",
                            url: "/User/UserEdit",
                            data: data,
                            success: function (obj) {
                                if (obj.status == true) {
                                    layer.msg(obj.msg, { icon: 6, title: '提示' }, function (index) {
                                        window.parent.window.location.href = '/User/UserList';
                                    });
                                } else {
                                    layer.confirm(obj.msg, { icon: 5, title: '提示' }, function (index) {
                                        layer.close();
                                        location.reload();
                                    });
                                }
                            }
                        })
                        layer.close();
                    });
                    return false;

                })
            })
        });
    </script>

</head>
<body>
    <form id="myfrom" class="tab-content layui-form" action="" lay-filter="example">

        @{
            if (returnMsg.code == 200)
            {
                @Html.HiddenFor(m => m.Id)
                @Html.Hidden("AddOrEdit", (string)ViewBag.AddOrEdit)<div class="layui-fluid">
                    <div class="layui-row">
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>员工账号
                            </label>
                            <div class="layui-input-inline">
                                @{
                                    if (Model.Id > 0)
                                    {
                                        @Html.TextBoxFor(m => m.Name, new { @datatype = "s2-10", @class = "layui-input", @sucmsg = " ", id = "name", placeholder = "请输入员工账号，用于登录系统", @readonly = "readonly" })
                                    }
                                    else
                                    {
                                        @Html.TextBoxFor(m => m.Name, new { @datatype = "s2-10", @class = "layui-input", @sucmsg = " ", id = "name", placeholder = "请输入员工账号，用于登录系统" })
                                    }
                                }
                            </div> <span class="x-red">*请输入员工账号，用于登录系统</span>
                        </div>
                        <div class="layui-form-item ">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>登录密码
                            </label>
                            <div class="layui-input-inline">
                                <input type="password" name="Pwd" value="@Model.Pwd" datatype="s2-10" class="layui-input" sucmsg=" " placeholder="请输入登录密码" />
                            </div> <span class="x-red">*请输入登录密码</span>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>员工姓名
                            </label>
                            <div class="layui-input-inline">
                                @Html.TextBoxFor(m => m.Nickname, new { @datatype = "s2-10", @class = "layui-input", @sucmsg = " ", id = "Nickname", placeholder = "请输入员工姓名" })
                            </div> <span class="x-red">*请输入员工姓名</span>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>员工角色
                            </label>
                            <div class="layui-input-inline">
                                @Html.DropDownListFor(m => m.RoleType, ViewData["RoleList"] as SelectList, new { @class = "layui-input layui-select", id = "RoleType", @lay_filter = "RoleType", })
                            </div> <span class="x-red">*请选择员工角色</span>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>员工手机
                            </label>
                            <div class="layui-input-inline">
                                @Html.TextBoxFor(m => m.Telephone, new { @datatype = "n", @class = "layui-input", @sucmsg = " ", placeholder = "请输入员工手机号码" })
                            </div><span class="x-red">*请输入员工手机号</span>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>通知邮箱
                            </label>
                            <div class="layui-input-inline">
                                @Html.TextBoxFor(m => m.Email, new { @datatype = "n", @class = "layui-input", @sucmsg = " ", placeholder = "请输入邮箱方便接受通知" })
                            </div><span class="x-red">*请输入邮箱方便接受通知</span>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>子用户数量
                            </label>
                            <div class="layui-input-inline">
                                @Html.TextBoxFor(m => m.ChildCount, new { @datatype = "n", @class = "layui-input", @sucmsg = " ", placeholder = "请输入子用户数量" })
                            </div><span class="x-red">*该用户可创建的子最大用户数</span>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red"></span>
                            </label>
                            <div class="layui-input-inline">
                                <input id="btnSubmit" name="btnSubmit" type="submit" value="保存信息" class="layui-btn" />
                            </div>
                        </div>
                    </div>
                </div>
            }
            else
            {
                <p id="" class="layui-layer-contents">
                    @returnMsg.msg
                </p>
            }
        }

        <script>
            layui.use(['form', 'layer'],
                function () {
                    $ = layui.jquery;
                    var form = layui.form,
                        layer = layui.layer;
                });
        </script>
    </form>
</body>
</html>
